var t = require("../../services/api.js");

require("../../utils/util.js");

Page({
    data: {
        lists: [],
        page: 1,
        count: 0,
        keyword: "",
        type: 0,
        typeNmae: ""
    },
    onLoad: function(t) {
        var a = this, e = t.type, n = t.keyword;
        e && n || wx.showModal({
            title: "提示",
            content: "无效搜索",
            showCancel: !1,
            success: function() {
                wx.navigateBack();
            }
        }), this.setData({
            type: e,
            keyword: decodeURIComponent(n),
            typeNmae: 0 == e ? "团购" : "任务"
        }, function() {
            a.getLists();
        });
    },
    getLists: function() {
        var a = this, e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 1, n = this.data, o = n.type, s = n.keyword;
        0 == o ? (0, t.getGoods)({
            title: s,
            page: e,
            pageSize: 8
        }).then(function(t) {
            200 === t.data.code ? a.setData({
                lists: e > 1 ? [].concat(a.data.lists, t.data.data.list) : t.data.data.list,
                count: t.data.data.count,
                page: e
            }) : wx.showModal({
                title: "提示",
                content: t.data.message,
                showCancel: !1
            });
        }) : (0, t.getTaskLists)({
            title: s,
            page: e,
            pageSize: 8
        }).then(function(t) {
            200 === t.data.code ? a.setData({
                lists: e > 1 ? [].concat(a.data.lists, t.data.data.list) : t.data.data.list,
                count: t.data.data.count,
                page: e
            }) : wx.showModal({
                title: "提示",
                content: t.data.message,
                showCancel: !1
            });
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        var t = this.selectComponent("#pagination");
        if (!t) return !1;
        var a = t.hasMore();
        a && this.getLists(a);
    },
    onShareAppMessage: function() {}
});